package com.cdx.example.consumer;

import com.cdx.example.common.model.User;
import com.cdx.example.common.service.UserService;
import com.cdx.rpc.proxy.ServiceProxyFactory;


/**
 * 简易服务消费者示例
 */
public class EasyConsumerExample {

    public static void main(String[] args) throws InterruptedException {
        // 动态代理
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setName("yupi");
        // 调用
        for (int i = 0; i < 3; i++) {
            User newUser = userService.getUser(user);
            if (newUser != null) {
                System.out.println(newUser.getName());
            } else {
                System.out.println("user == null");
            }
        }

    }
}
